import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { MenuVO, MenuForm, MenuQuery } from '@/api/system/appMenu/types';

/**
 * 查询移动端应用菜单列表
 * @param query
 * @returns {*}
 */

export const listMenu = (query?: MenuQuery): AxiosPromise<MenuVO[]> => {
  return request({
    url: '/system/appMenu/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询移动端应用菜单详细
 * @param appMenuId
 */
export const getMenu = (appMenuId: string | number): AxiosPromise<MenuVO> => {
  return request({
    url: '/system/appMenu/' + appMenuId,
    method: 'get'
  });
};

/**
 * 新增移动端应用菜单
 * @param data
 */
export const addMenu = (data: MenuForm) => {
  return request({
    url: '/system/appMenu',
    method: 'post',
    data: data
  });
};

/**
 * 修改移动端应用菜单
 * @param data
 */
export const updateMenu = (data: MenuForm) => {
  return request({
    url: '/system/appMenu',
    method: 'put',
    data: data
  });
};

/**
 * 删除移动端应用菜单
 * @param appMenuId
 */
export const delMenu = (appMenuId: string | number | Array<string | number>) => {
  return request({
    url: '/system/appMenu/' + appMenuId,
    method: 'delete'
  });
};
